<!DOCTYPE HTML>
<html lang="en">
<head>
<title>#KeyHistory - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The #KeyHistory directive sets the maximum number of keyboard and mouse events displayed by the KeyHistory window." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#KeyHistory</h1>

<p>Sets the maximum number of keyboard and mouse events displayed by the <a href="KeyHistory.htm">KeyHistory</a> window. You can set it to 0 to disable key history.</p>

<pre class="Syntax"><span class="func">#KeyHistory</span> MaxEvents</pre>
<h2>Parameters</h2>
<dl>

  <dt>MaxEvents</dt>
  <dd><p>The maximum number of keyboard and mouse events displayed by the <a href="KeyHistory.htm">KeyHistory</a> window (default 40, limit 500). Specify 0 to disable key history entirely.</p></dd>

</dl>
<h2>Remarks</h2>
<p>Because this setting is put into effect before the script begins running, it is only necessary to specify it once (anywhere in the script).</p>
<p>Because each keystroke or mouse click consists of a down-event and an up-event, <a href="KeyHistory.htm">KeyHistory</a> displays only half as many &quot;complete events&quot; as specified here. For example, if the script contains <code>#KeyHistory 50</code>, up to 25 keystrokes and mouse clicks will be displayed.</p>
<h2>Related</h2>
<p><a href="KeyHistory.htm">KeyHistory</a>, <a href="_NoTrayIcon.htm">#NoTrayIcon</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>#KeyHistory 0    <em>; Disable key history.</em>
#KeyHistory 100  <em>; Store up to 100 events.</em></pre>
</div>

</body>
</html>
